package saeildamil.ch18.critical;

public class PrintThread extends Thread {
	SharedAccount sharedAccount;

	public PrintThread(SharedAccount sharedAccount) {
		this.sharedAccount = sharedAccount;
	}
	
	@Override
	public void run() {
		//이몽룡, 성춘향 계좌 잔액 합계 계산 3번 반복
		int sum = 0;
		for(int i=0; i<3; i++){
			sum = sharedAccount.getTotal();
			System.out.println("계좌 잔액 합계: " + sum);
			try {
				sleep(1);
			} catch (InterruptedException e) {
				System.out.println(e.getMessage());			
			}

		
				}
	}
}
